#encoding=utf8
'''
Created on 2012-10-17

@author: Administrator
'''
from DbOperator import DbOperator
from Idiom import  Idiom
from pub import Func
from pub.Config import Config
class IdiomModel(DbOperator):
    '''
    classdocs
    '''


    def __init__(self):
        '''
        Constructor
        '''
        DbOperator.__init__(self)
    def validIdiom(self,sIdiomLetters):
        '''
        检测成语是否存在于成语库中
        @param sIdiomLetters:string
        @return:bool 
        '''
        aParam = {
          Config.S_TABLE:Idiom.TABLE_NAME,
          Config.S_SEARCHFIELDS:"`%s`"%Idiom.IDIOMID,
          Config.S_SEARCHCONDITION:" `%s`='%s'" % (Idiom.LETTER,sIdiomLetters),
          Config.S_RESULTROW:1,
          }
        result = self.getFieldByCondition(aParam)
        if(result != None): 
            return True;
        else:
            return False;
if __name__=="__main__":
    mIdiom = IdiomModel();
    print mIdiom.validIdiom("哀兵必胜")
    